home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_06
/
9n06060b
< prev
next >
Wrap
Text File
|
1991-02-23
|
1KB
|
60 lines
// class StructThing -- a struct thing derived from
// class Thing.
//
// Version 1.01 -- 2/25/91
//
// Michael Kelly -- Author
//
#include <stdio.h>
#include <string.h>
#include "th_struc.hpp"
void StructThing::print()
{
printf(
"%d %s\n",
((a_struct)*this).id,
((a_struct)*this).key
);
}
StructThing::operator ==(Thing &some_thing)
{
return ( type() == some_thing.type() ) ?
( strcmp( ((a_struct *)ptr())->key,
((a_struct *)some_thing.ptr())->key) == 0 ) : 0;
}
StructThing::operator !=(Thing &some_thing)
{
return !( *this == some_thing );
}
StructThing::operator < (Thing &some_thing)
{
return ( type() == some_thing.type() ) ?
( strcmp( ((a_struct *)ptr())->key,
((a_struct *)some_thing.ptr())->key) < 0 ) : 0;
}
StructThing::operator <=(Thing &some_thing)
{
return ( type() == some_thing.type() ) ?
( strcmp( ((a_struct *)ptr())->key,
((a_struct *)some_thing.ptr())->key) <= 0 ) : 0;
}
StructThing::operator > (Thing &some_thing)
{
return ( type() == some_thing.type() ) ?
( strcmp( ((a_struct *)ptr())->key,
((a_struct *)some_thing.ptr())->key) > 0 ) : 0;
}
StructThing::operator >=(Thing &some_thing)
{
return ( type() == some_thing.type() ) ?
( strcmp( ((a_struct *)ptr())->key,
((a_struct *)some_thing.ptr())->key) >= 0 ) : 0;
}